
<template>
    <div class="container">
<!--        {{childrenData}}-->
        <div class="group-btn">
            <el-button v-if="childrenData.orgTypeName != '套户'" type="primary" @click="add('组织')">新增组织</el-button>
            <el-button v-if="childrenData.orgTypeName == '组织'&&childrenData.orgTypeName != '套户'" type="primary" @click="add('区域')">新增区域</el-button>
            <el-button v-if="(childrenData.orgTypeName == '组织'||childrenData.orgTypeName == '区域')&&childrenData.orgTypeName != '套户'" type="primary" @click="add('建筑')">新增建筑</el-button>
            <el-button v-if="(childrenData.orgTypeName == '建筑')&&childrenData.orgTypeName != '套户'" type="primary" @click="add('单元')">新增单元</el-button>
            <el-button v-if="(childrenData.orgTypeName == '建筑'||childrenData.orgTypeName == '单元')&&childrenData.orgTypeName != '套户'" type="primary" @click="add('楼层')">新增楼层</el-button>
            <el-button v-if="childrenData.orgTypeName == '建筑'&&childrenData.orgTypeName != '套户'" type="primary" @click="add('改造')">新增改造信息</el-button>
            <el-button v-if="childrenData.orgTypeName == '楼层'" type="primary" @click="add('套户')">新增套户</el-button>
            <el-button v-if="childrenData.orgTypeName == '建筑'&&isOrgExtendBank" type="primary" @click="addExend">扩展信息</el-button>
            <el-button type="success" @click="editOrg">修改</el-button>
            <el-button type="danger" @click="deleteOrg">删除</el-button>
        </div>
        <el-tabs v-model="activeName2" type="card" @tab-click="handleClick">
            <el-tab-pane label="基本信息" name="first">
                <el-form   label-width="80px">
                    <el-form-item label="上级组织">
                        <el-input class="el_input" :disabled="isDisabled"  v-model="childrenData.pname" style="width:260px;"></el-input>
                    </el-form-item>
                    <el-form-item label="名称">
                        <el-input class="el_input" :disabled="isDisabled" v-model="childrenData.orgName" style="width:260px;"></el-input>
                    </el-form-item>
                    <el-form-item label="编号">
                        <el-input class="el_input" :disabled="isDisabled" v-model="childrenData.orgNo" style="width:260px;"></el-input>
                    </el-form-item>
                    <el-form-item label="类型">
                        <el-input class="el_input" :disabled="isDisabled" v-model="childrenData.orgTypeName" style="width:260px;"></el-input>
                    </el-form-item>
                    <el-form-item label="字母简写">
                        <el-input class="el_input" :disabled="isDisabled" v-model="childrenData.simpleName" style="width:260px;"></el-input>
                    </el-form-item>
                    <el-form-item label="全称">
                        <el-input class="el_input" :disabled="isDisabled" v-model="childrenData.orgFullPath" style="width:260px;"></el-input>
                    </el-form-item>
                    <el-form-item label="描述信息" style="width:500px;height:140px;">
                        <el-input type="textarea" :disabled="isDisabled" v-model="childrenData.description"></el-input>
                    </el-form-item>
                </el-form>
            </el-tab-pane>
            <!--<el-tab-pane label="扩展信息" name="second">-->
                <!--<el-form   label-width="130px">-->
                    <!--<el-form-item label="业主" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.buildOwner" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="数据中心" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.dataCenterId" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="是否标杆建筑" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.isStandard?'是':'否'" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="建筑地址" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.buildAddress" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="建筑年代" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.buildYear" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="地上层数" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.upFloor" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="地下层数" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.downFloor" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="建筑面积" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.totalArea" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="空调面积" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.airArea" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="采暖面积" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.heatArea" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="建筑人数" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.buildPeopleNum" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="建筑结构" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.struType" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="空调系统" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.airType" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="采暖系统" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.heatType" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="外墙材料" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.wallMatType" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="外墙保温" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.wallMarmType" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="建筑类型" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.buildTypeName" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="玻璃类型" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.glassType" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="窗框材料" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.winFrameType" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="监测方案设计单位" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.designDept" ></el-input>-->
                    <!--</el-form-item>-->
                    <!--<el-form-item label="监测工程实施单位" class="limit-width">-->
                        <!--<el-input class="el_input" :disabled="isDisabled"  v-model="getOrgExtendData.workDept" ></el-input>-->
                    <!--</el-form-item>-->

                <!--</el-form>-->
            <!--</el-tab-pane>-->
<!--            <el-tab-pane label="设备列表" name="third">-->
<!--                <el-table-->
<!--                        :data="tableData"-->
<!--                        style="width: 100%">-->
<!--                    <el-table-column-->
<!--                            prop="equipmentNumber"-->
<!--                            label="设备编号">-->
<!--                    </el-table-column>-->
<!--                    <el-table-column-->
<!--                            prop="equipmentName"-->
<!--                            label="设备名称">-->
<!--                    </el-table-column>-->
<!--                    <el-table-column-->
<!--                            prop="equipmentSerialNumber"-->
<!--                            label="设备序号">-->
<!--                    </el-table-column>-->
<!--                    <el-table-column-->
<!--                            prop="equipmentUse"-->
<!--                            label="设备用途">-->
<!--                    </el-table-column>-->
<!--                    <el-table-column-->
<!--                            prop="equipmentState"-->
<!--                            label="设备状态">-->
<!--                    </el-table-column>-->
<!--                </el-table>-->
<!--            </el-tab-pane>-->
            <!--<el-tab-pane label="改造信息" name="fourth">-->
                <!--<el-button type="danger" @click="deleteReno" style="margin-bottom: 15px;">删除</el-button>-->
                <!--<el-table-->
                        <!--:data="reformData"-->
                        <!--style="width: 100%"-->
                        <!--border-->
                        <!--@selection-change="styleSelectionChange">-->
                    <!--<el-table-column type="selection" width="55" align="center"></el-table-column>-->
                    <!--<el-table-column-->
                            <!--prop="renoDept"-->
                            <!--label="改造单位"-->
                            <!--align="center">-->
                    <!--</el-table-column>-->
                    <!--<el-table-column-->
                            <!--prop="renoDate"-->
                            <!--label="改造时间"-->
                            <!--align="center"-->
                            <!--:formatter="formatTime">-->
                    <!--</el-table-column>-->
                    <!--<el-table-column-->
                            <!--prop="remarks"-->
                            <!--label="改造描述"-->
                            <!--align="center">-->
                    <!--</el-table-column>-->

                <!--</el-table>-->
            <!--</el-tab-pane>-->
        </el-tabs>
        <!-- 新增组织弹出框 -->
        <el-dialog :title="delogTitle" :visible.sync="addVisible" width="70%">
            <el-form  :model="form" label-width="120px">
                <el-form-item label="上级组织">
                    <el-input class="el_input form_wid"  :disabled="isDisabled" v-model="childrenData.orgName"></el-input>
                </el-form-item>
                <el-form-item label="类型">
                    <el-input class="el_input form_wid" :disabled="isDisabled"  v-model="form.type"></el-input>
                </el-form-item>
                <el-form-item label="编号">
                    <el-input class="el_input form_wid"  v-model="form.code"></el-input>
                </el-form-item>
                <el-form-item label="名称">
                    <el-input class="el_input form_wid"  v-model="form.name"></el-input>
                </el-form-item>
                <el-form-item label="字母简写">
                    <el-input class="el_input form_wid"  v-model="form.letter"></el-input>
                </el-form-item>
<!--                <el-form-item label="全称">-->
<!--                    <el-input class="el_input form_wid" disabled v-model="form.fullName"></el-input>-->
<!--                </el-form-item>-->
                <el-form-item label="描述信息" style="width: 80%;">
                    <el-input type="textarea"  v-model="form.desc"></el-input>
                </el-form-item>
            </el-form>

            <span slot="footer" class="dialog-footer">
                <el-button @click="addVisible = false">取 消</el-button>
                <el-button type="primary" @click="saveForm(form)">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 新增改造弹出框 -->
        <el-dialog title="新增改造信息" :visible.sync="addGaizao" width="70%">

            <el-form  :model="form" label-width="120px">
                <el-form-item label="改造建筑">
                    <el-input class="el_input form_wid" disabled v-model="gaizaoData.buildName"></el-input>
                </el-form-item>
                <el-form-item label="改造单位">
                    <el-input class="el_input form_wid" v-model="gaizaoData.renoDept"></el-input>
                </el-form-item>
                <el-form-item label="改造时间">
                    <el-col>
                        <el-date-picker type="date" placeholder="选择日期" value-format="yyyy-MM-dd" v-model="gaizaoData.renoDate" style=""></el-date-picker>
                    </el-col>
                </el-form-item>
                <el-form-item label="改造描述" style="width: 80%;">
                    <el-input type="textarea"  v-model="gaizaoData.remarks"></el-input>
                </el-form-item>

            </el-form>

            <span slot="footer" class="dialog-footer">
                <el-button @click="addGaizao = false">取 消</el-button>
                <el-button type="primary" @click="saveGaizao()">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 新增扩展弹出框 -->
        <el-dialog title="建筑扩展信息" :visible.sync="visibileExend" width="70%">
            <el-form  :model="form" label-width="120px" class="limit-small">
                <el-form-item label="业主">
                    <el-input class="el_input form_wid"  v-model="buildExend.buildOwner"></el-input>
                </el-form-item>
                <el-form-item label="数据">
                    <el-input class="el_input form_wid" v-model="buildExend.dataCenterId"></el-input>
                </el-form-item>
                <el-form-item label="是否标杆建筑">
                    <el-switch v-model="buildExend.isStandard"></el-switch>
                </el-form-item>
                <el-form-item label="建筑地址">
                    <el-input class="el_input form_wid"  v-model="buildExend.buildAddress"></el-input>
                </el-form-item>
                <el-form-item label="建筑年代">
                    <el-col>
                        <el-date-picker type="date" placeholder="选择日期" value-format="yyyy-MM-dd" v-model="buildExend.buildYear" style=""></el-date-picker>
                    </el-col>
                </el-form-item>
                <el-form-item label="地上层数">
                    <el-input class="el_input form_wid" v-model="buildExend.upFloor"></el-input>
                </el-form-item>
                <el-form-item label="地下层数">
                    <el-input class="el_input form_wid" v-model="buildExend.downFloor"></el-input>
                </el-form-item>
                <el-form-item label="建筑面积(㎡)">
                    <el-input class="el_input form_wid" v-model="buildExend.totalArea"></el-input>
                </el-form-item>
                <el-form-item label="空调面积(㎡)">
                    <el-input class="el_input form_wid" v-model="buildExend.airArea"></el-input>
                </el-form-item>
                <el-form-item label="采暖面积(㎡)">
                    <el-input class="el_input form_wid" v-model="buildExend.heatArea"></el-input>
                </el-form-item>
                <el-form-item label="建筑人数">
                    <el-input class="el_input form_wid" v-model="buildExend.buildPeopleNum"></el-input>
                </el-form-item>
                <el-form-item label="建筑结构">
                    <el-select v-model="buildExend.struType" placeholder="请选择">
                        <el-option v-for="item in dicClassData.jgxs" :label="item.name" :value="item.value.toString()" :key="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="空调系统">
                    <el-select v-model="buildExend.airType" placeholder="请选择">
                        <el-option v-for="item in dicClassData.ktxs" :label="item.name" :value="item.value.toString()" :key="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="采暖系统">
                    <el-select v-model="buildExend.heatType" placeholder="请选择">
                        <el-option v-for="item in dicClassData.cnxs" :label="item.name" :value="item.value.toString()" :key="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="外墙材料">
                    <el-select v-model="buildExend.wallMatType" placeholder="请选择">
                        <el-option v-for="item in dicClassData.wqxs" :label="item.name" :value="item.value.toString()" :key="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="外墙保温">
                    <el-select v-model="buildExend.wallMarmType" placeholder="请选择">
                        <el-option v-for="item in dicClassData.wqbw" :label="item.name" :value="item.value.toString()" :key="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="建筑类型">
                    <el-select v-model="buildExend.buildTypeName" placeholder="请选择">
                        <el-option v-for="item in dicClassData.jzlx" :label="item.name" :value="item.value.toString()" :key="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="玻璃类型">
                    <el-select v-model="buildExend.glassType" placeholder="请选择">
                        <el-option v-for="item in dicClassData.bllx" :label="item.name" :value="item.value.toString()" :key="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="窗框材料">
                    <el-select v-model="buildExend.winFrameType" placeholder="请选择">
                        <el-option v-for="item in dicClassData.ckcl" :label="item.name" :value="item.value.toString()" :key="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="方案设计单位">
                    <el-input class="el_input form_wid" v-model="buildExend.designDept"></el-input>
                </el-form-item>
                <el-form-item label="工程施工单位">
                    <el-input class="el_input form_wid" v-model="buildExend.workDept"></el-input>
                </el-form-item>
            </el-form>


            <span slot="footer" class="dialog-footer">
                <el-button @click="visibileExend = false">取 消</el-button>
                <el-button type="primary" @click="saveExend">确 定</el-button>
            </span>
        </el-dialog>
    </div>

</template>

<script>
    import {regionalAdd,deleteOrg,editOrg,getBuildInfo,addOrgExtendInfo,addOrgBuildingRenoInfo,getOrgRenoInfo,getOrgExtendInfo,getOrgExtendInfoBeforeUpdate,updateExtendInfo,deleteBuildingRenoInfoByIds} from  '../../../api/index';
    import {clearObjValue,famatDatesTimes} from '../../common/com';
    export default {
        name: "all",
        props:['childrenData'],
        data(){
            return{
                addVisible:false,
                isDisabled:true,
                isEditInfo:false,
                activeName2: 'first',
                delogTitle:'新增组织',
                addTypeName:'',
                isBuild:false,
                isEdit:false,
                addGaizao:false,
                selectTabIndex:0,
                visibileExend:false,
                getOrgExtendData:{},
                postDicClass:[
                    {"dicName":"建筑类型"},
                    {"dicName":"空调形式"},
                    {"dicName":"采暖形式"},
                    {"dicName":"结构形式"},
                    {"dicName":"外墙形式"},
                    {"dicName":"外墙保温"},
                    {"dicName":"玻璃类型"},
                    {"dicName":"窗框材料"}
                    ],
                dicClassData:{
                    jzlx:[],ktxs:[],cnxs:[],jgxs:[],wqxs:[],wqbw:[],bllx:[],ckcl:[]
                },
                buildExend:{
                    groupId:this.childrenData.id,
                    dataCenterId:'',
                    buildOwner:'',
                    buildAddress:'',
                    buildYear:'',
                    upFloor:'',
                    downFloor:'',
                    totalArea:'',
                    airArea:'',
                    heatArea:'',
                    buildPeopleNum:'',
                    struType:'',
                    airType:'',
                    buildTypeName:'',
                    heatType:'',
                    wallMatType:'',
                    wallMarmType:'',
                    glassType:'',
                    winFrameType:'',
                    isStandard:'',
                    designDept:'',
                    workDept:''
                },
                form:{
                    pid:'',
                    upName:'',
                    name:'',
                    code:'',
                    type:this.isEdit?this.childrenData.orgTypeName:this.addTypeName,
                    letter:'',
                    fullName:this.childrenData.orgFullPath?this.childrenData.orgFullPath:this.childrenData.orgFullName,
                    desc:''
                },
                gaizaoData:{
                    rebuildGroupId:this.childrenData.id,
                    renoDate:'',
                    renoDept:'',
                    remarks:'',
                    buildName:''
                },
                tableData: [{
                    equipmentNumber: 'water_01',
                    equipmentName: '水表1',
                    equipmentSerialNumber: '教学楼一楼一教室',
                    equipmentUse:'水表检测',
                    equipmentState:'正常'
                },{
                    equipmentNumber: 'water_02',
                    equipmentName: '水表2',
                    equipmentSerialNumber: '教学楼一楼二教室',
                    equipmentUse:'水表检测',
                    equipmentState:'正常'
                },
                ],
                reformData:[],
                renoDataDel:[],
                isOrgExtendBank:true,
            };
        },
        created() {
            this.childMethod();
            for(var i=0;i<this.postDicClass.length;i++){
                this.getBuildInfo(this.postDicClass[i],i);
            }

        },
        mounted(){

        },
        watch:{
            childrenData:function(val){
                this.activeName2 = 'first';
                this.selectTabIndex = 0;
                if(val.orgTypeName == '建筑'){
                    this.getOrgExtendInfo();
                }
            }
        },

        updated(){
            // this.$nextTick(()=>{
            //     console.log(this.childrenData)
            // })
        },
        methods:{
            handleClick(tab, event) {
                // console.log(tab.index);
                this.selectTabIndex = tab.index;
                if(tab.index == 1){
                    this.getOrgExtendInfo()
                }
                if(tab.index==2){
                    this.getOrgRenoInfo()
                }

            },
            styleSelectionChange(val){
                var selectArr = []
                for(var i=0;i<val.length;i++){
                    if(val[i]){
                        selectArr.push(val[i])
                    }
                }
                this.renoDataDel = selectArr;
               console.log(selectArr)
            },
            childMethod(){
                this.$emit('fatherGetSubOrgList');
              // this.$parent.getSubOrgList();
            },
            formatTime(row, column, cellValue, index){
                return famatDatesTimes(cellValue);
            },
            //保存
            saveForm(formname){
                if (this.formValidate(this.form)) {
                    var postData;
                    if(this.isEdit){
                        postData = {
                            createTime:this.childrenData.createTime,
                            description:this.form.desc,
                            id:this.childrenData.id,
                            orgFullName:this.form.fullName,
                            orgName:this.form.name,
                            orgNo:this.form.code,
                            pid:this.childrenData.pid,
                            simpleName:this.form.letter,
                            orgTypeName:this.childrenData.orgTypeName,
                        }
                        editOrg(postData).then((res)=>{
                            if(res.success){
                                    this.childrenData.description = this.form.desc;
                                    this.childrenData.orgFullName = this.form.fullName;
                                    this.childrenData.orgName = this.form.name;
                                    this.childrenData.orgNo = this.form.code;
                                    this.childrenData.simpleName = this.form.letter;
                                    this.addVisible = false;
                                    this.$message.success(res.message)
                            }else{
                                this.$message.error(res.message)
                            }
                        })

                        return;
                    }

                    var orgFullSrc = this.childrenData.orgFullPath?this.childrenData.orgFullPath:this.childrenData.orgFullName;
                    postData={
                        pid:this.childrenData.id,
                        orgName:this.form.name,
                        orgNo:this.form.code,
                        orgTypeName:this.form.type,
                        simpleName:this.form.letter,
                        orgFullName:orgFullSrc+'/'+this.form.name,
                        description:this.form.desc,
                    }

                    // if(this.isBuild){
                    //     postData = {
                    //         baseInfo:postData,
                    //         buildExend: this.buildExend
                    //     }
                    // }
                    // console.log(postData)
                    regionalAdd(postData).then((res) =>{
                        if(res.success) {
                            console.log(res)
                            this.$message.success(`添加成功`);
                            this.addVisible = false;
                            this.childMethod();
                            this.$emit('fatherRefreshLazyData','add');
                            // this.$parent.refreshLazyData('add')
                        }else{
                            this.$message.error(res.message);
                        }
                        })
                    return;
                }

            },
            //点击新增组织
            add(ty){
                this.isEdit = false;
                if(ty == '建筑'){
                    this.isBuild = true;
                }else{
                    if(ty == '改造'){
                        this.addGaizao = true;
                        this.gaizaoData.buildName = this.childrenData.orgName;
                        this.gaizaoData.rebuildGroupId = this.childrenData.id;
                        return ;
                    }
                    this.isBuild =false;
                }
                this.addTypeName = ty;
                this.addVisible = true;
                this.delogTitle = '新增'+ty;
                this.buildExend = clearObjValue(this.buildExend);
                this.form = clearObjValue(this.form);
                this.form.fullName = this.childrenData.orgFullPath;
                this.form.type = this.addTypeName;
            },
            //验证
            formValidate(formname){
                if(formname.code&&formname.name&&formname.letter&&formname.desc){
                    return true;
                    // if(!formname.upName){
                    //     this.$message.error('请输入上级组织');
                    //     return false;
                    // }
                    // if(!formname.name){
                    //     this.$message.error('请输入名称');
                    //     return false;
                    // }

                }else{
                    if(!formname.code){
                        this.$message.error('请输入编号');
                        return false;
                    }
                    if(!formname.name){
                        this.$message.error('请输入名称');
                        return false;
                    }
                    if(!formname.letter){
                        this.$message.error('请输入字母简称');
                        return false;
                    }

                    if(!formname.desc){
                        this.$message.error('请输入描述');
                        return false;
                    }
                }
            },
            //删除
            deleteOrg(){
                deleteOrg({
                    subId:this.childrenData.id
                }).then((res)=>{
                    if(res.success){
                        this.$message.success(res.message)
                        this.$emit('fatherRefreshLazyData');
                        // this.$parent.refreshLazyData();
                    }else{
                        this.$message.error(res.message)
                    }
                })
            },
            //修改
            editOrg(){
                // console.log(this.selectTabIndex)
                // console.log(this.childrenData.orgTypeName)
                if(this.selectTabIndex>1){
                    return ;
                }else if(this.selectTabIndex == 1 && this.childrenData.orgTypeName == '建筑'){
                    getOrgExtendInfoBeforeUpdate(
                        { buildId:this.childrenData.id}
                    ).then((res)=>{
                        // console.log(this.dicClassData.ckcl)
                        this.buildExend = res.data;
                        this.buildExend.buildYear = famatDatesTimes(this.buildExend.buildYear,'Y')
                    })

                    this.visibileExend = true;
                }else{
                    this.addVisible = true;
                    this.form ={
                        pid:this.childrenData.pid,
                        code:this.childrenData.orgNo,
                        type:this.childrenData.orgTypeName,
                        letter:this.childrenData.simpleName,
                        fullName:this.form.fullName,
                        desc:this.childrenData.description,
                        name:this.childrenData.orgName
                    };
                }
                this.isEdit = true;
                this.delogTitle = this.selectTabIndex==0?'修改基本信息':'修改扩展信息';
            },
            //获取新增扩展信息的下拉选项
            getBuildInfo(d,k){
                // console.log(d)
                getBuildInfo(d).then((res)=>{
                    // console.log(res)
                    switch (k) {
                        case 0:
                            this.dicClassData.jzlx = res;
                            break;
                        case 1:
                            this.dicClassData.ktxs = res;
                            break;
                        case 2:
                            this.dicClassData.cnxs = res;
                            break;
                        case 3:
                            this.dicClassData.jgxs = res;
                            break;
                        case 4:
                            this.dicClassData.wqxs = res;
                            break;
                        case 5:
                            this.dicClassData.wqbw = res;
                            break;
                        case 6:
                            this.dicClassData.bllx = res;
                            break;
                        case 7:
                            this.dicClassData.ckcl = res;
                            break;
                    }
                })
            },
            //保存改造信息
            saveGaizao(){
                // console.log(this.gaizaoData)
                addOrgBuildingRenoInfo(this.gaizaoData).then((res)=>{
                    if(res.success){
                        this.addGaizao = false
                        this.$message.success(res.message)
                    }else{
                        this.$message.error(res.message)
                    }
                })
            },
            //点击扩展信息
            addExend(){
                this.visibileExend = true;
                this.buildExend = clearObjValue(this.buildExend)
            },
            //保存扩展信息
            saveExend(){
                if(this.isEdit){
                    updateExtendInfo(this.buildExend).then((res)=>{
                        if(res.success){
                            this.$message.success('修改成功')
                            this.getOrgExtendInfo();
                            this.visibileExend = false
                        }else{
                            this.$message.error(res.message)
                        }
                    })
                    return ;
                }
                delete this.buildExend.buildId;
                this.buildExend.groupId = this.childrenData.id;
                addOrgExtendInfo(this.buildExend).then((res)=>{
                    if(res.success){
                        this.visibileExend = false
                        this.$message.success(res.message)
                        this.getOrgExtendInfo();
                    }else{
                        this.$message.error(res.message)
                    }
                })
            },
            //获取改造信息
            getOrgRenoInfo(){
                getOrgRenoInfo({
                    buildId:this.childrenData.id
                }).then((res)=>{
                    this.reformData = res.datas;
                })
            },
            //获取扩展信息
            getOrgExtendInfo(){
                getOrgExtendInfo({
                    buildId:this.childrenData.id
                }).then((res)=>{
                    if(res.data){
                        this.getOrgExtendData = res.data;
                        this.getOrgExtendData.buildYear = famatDatesTimes( this.getOrgExtendData.buildYear,'Y')
                        this.isOrgExtendBank = false;
                    }else{
                        this.getOrgExtendData = clearObjValue(this.getOrgExtendData);
                        this.isOrgExtendBank = true;
                    }

                })
            },
            //删除改造信息
            deleteReno(){
               if(this.renoDataDel.length<1){
                   this.$message.error('请选择需要删除的列表')
                   return;
               }
                var ids = new Array();
                for(var i=0;i<this.renoDataDel.length;i++){
                    ids.push(this.renoDataDel[i].rebuildId)
                }
                deleteBuildingRenoInfoByIds({ids:ids}).then((res)=>{
                    if(res.success){
                        this.$message.success(res.message)
                        this. getOrgRenoInfo();
                    }else{
                        this.$message.error(res.message)
                    }
                })
            }

        }
    }
</script>

<style scoped>
    form{
        margin-left:20px;
    }

    .el_input{
        width:220px;
    }
    el-row {
        margin-bottom: 20px;
    }
    el-row :last-child {
         margin-bottom: 0;
     }

    el-col {
        border-radius: 4px;
    }
    bg-purple-dark {
        background: #99a9bf;
    }
    .bg-purple {
        background: #d3dce6;
    }
    .bg-purple-light {
        background: #e5e9f2;
    }
    .grid-content {
        border-radius: 4px;
        min-height: 36px;
    }
    .row-bg {
        padding: 10px 0;
        background-color: #f9fafc;
    }
    .limit-width{
        width: 30%;
        float: left;
    }
    .limit-small .el-form-item{
        float: left;
        width: 50%;
    }
    .limit-small{
        overflow: hidden;
    }
    .border-bottom{
        border-bottom: 1px solid #DCDFE6;
        padding-bottom: 15px;
        margin-bottom: 15px;
    }
    .el-dialog .el-dialog__body{
        max-height:600px;
        overflow-y: scroll;
    }
</style>
